package cn.itcast.web.controller.stat;

import cn.itcast.service.stat.StatService;
import cn.itcast.web.controller.BaseController;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/stat")
public class StatController extends BaseController {

    @Reference
    private StatService statService;

    @RequestMapping("/toCharts")
    public String toCharts(String chartsType) {  //factory
        return "stat/stat-"+chartsType;
    }

    /**
     * 生厂厂家销量统计
     *   业务：
     *      接受ajax请求
     *      调用service查询数据
     *      返回数据结果：json
     */
    @RequestMapping("/findFactoryData")
    @ResponseBody
    public List<Map> findFactoryData() {
        return statService.findFactoryData(getLoginCompanyId());
    }

    /**
     * 产品销量排行榜数据统计
     *   业务：
     *      接受ajax请求
     *      调用service查询数据
     *      返回数据结果：json
     *
     *
     */
    @RequestMapping("/findSellData")
    @ResponseBody
    public List<Map> findSellData() {
        return statService.findSellData(getLoginCompanyId());
    }

    /**
     * 系统访问压力图
     */
    @RequestMapping("/findOnlineData")
    @ResponseBody
    public List<Map> findOnlineData() {
        return statService.findOnlineData(getLoginCompanyId());
    }

    @RequestMapping("/findPriceData")
    @ResponseBody
    public List<Map> findPriceData() {
        return statService.findPriceData(getLoginCompanyId());
    }

    @RequestMapping("/findLoginData")
    @ResponseBody
    public List<Map> findLoginData() {
        return statService.findLoginData(getLoginCompanyId());
    }
}
